// pages/map/map.js

const util = require('../../utils/util.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {

    // 35.103725, 118.356442

    test: "test deta",

    markers: [{
        id: 0,
        longitude: 118.32314014434814,
        latitude: 35.00732708792252,
        title: "盛能游乐园",
        desc: "临沂市罗庄区",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      },
      {
        id: 1,
        latitude: 35.061617,
        longitude: 118.340607,
        title: "临沂人民广场",
        desc: "兰山区八一路9号",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      },
      {
        id: 2,
        latitude: 35.103725,
        longitude: 118.356442,
        title: "市政府",
        desc: "兰山区北城区北京路17号",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      },
      {
        id: 3,
        longitude: 118.30322742462158,
        latitude: 35.067501097092105,
        title: "华强领秀城",
        desc: "临沂市兰山区",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      },
      {
        id: 4,
        longitude: 118.38080763816833,
        latitude: 35.19473923043186,
        title: "临沂北站",
        desc: "临沂市兰山区",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      },
      {
        id: 5,
        longitude: 118.41317653656006,
        latitude: 35.04787255010542,
        title: "临沂启阳国际机场",
        desc: "临沂市河东区",
        iconPath: "/assets/ic_position.png",
        width: "60rpx",
        height: "60rpx",
      }
    ]

  },

  // 点击地图上的标记点
  onMarkerTap: function(e) {
    console.log(e);

    let index = e.markerId;
    let that = this;

    wx.showToast({
      // 打印出点击的marker的title
      title: that.data.markers[index].title,
      // title: '点击marker' + index,
    })
  },

  // 点击地图
  onMapTap: function(e) {
    console.log('点击地图');
    console.log(e.detail);
  },

  // 查看天气
  onCheckWeather: function() {
    util.navigateToWeather();
  },

  // 查看景点
  onCheckPlace: function() {
    util.navigateTo('/pages/place/place');
  },

  // 查看美食
  onCheckFood: function() {
    // wx.showToast({
    //   icon: 'loading',
    //   title: '美食敬请期待',
    // })
    util.navigateTo('/pages/food/food');
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

})